function mySqrt(x: number): number {
    if(x<2) return x
    if(x<4) return 1
    let l=0,
        r=x>>1;
    while(r>=l){
        let mid = (r+l)>>1
        if(mid*mid==x) return mid
        if(mid*mid<x&&(mid+1)*(mid+1)>x){
            return mid
        }else if((mid+1)*(1+mid)<=x){
            l = mid + 1
        }else{
            r = mid -1
        }
    }
};